<template>
  <div class="search">
    <f-form ref="form" :action="api.orderLogistics" :form-key="this.formItem.orderLogisticsId">
      <a-divider orientation="left">收货人信息</a-divider>
      <f-form-item label="收货人" name="receiveMan" :value="formItem.receiveMan" @change="updateLogistics"/>
      <f-form-item label="联系电话" name="receiveTel" :required="true" :value="formItem.receiveTel" @change="updateLogistics"/>
      <f-form-item label="收货地址" name="receiveAddress" :required="true" :value="formItem.receiveAddress" @change="updateLogistics"/>
      <f-form-item label="买家备注" name="leaveMsg" :value="formItem.leaveMsg" :disabled="true"/>
      <a-divider orientation="left">发货人信息</a-divider>
<!--      <f-form-item label="发货人" name="sellerMan" :required="true" :value="formItem.sellerMan" @change="updateLogistics"/>
      <f-form-item label="联系电话" name="sellerTel" :required="true" :value="formItem.sellerTel" @change="updateLogistics"/>
      <f-form-item label="发货地址" name="sendAddress" :required="true" :value="formItem.sendAddress" @change="updateLogistics"/>-->
      <f-form-item label="卖家留言" name="sellerMsg" :value="formItem.sellerMsg"/>
      <a-divider orientation="left">物流信息</a-divider>
      <f-form-item label="物流公司" name="logisticsId" type="select" :data="api.logistics.list" :required="true" :value="formItem.logisticsId" value-key="logisticsId" label-key="logisticsName"/>
      <f-form-item label="物流单号" name="logisticsNo" :required="true" :value="formItem.logisticsNo"/>
    </f-form>
  </div>
</template>

<script>

  export default {
    name: 'OrderLogistics',
    props: {},
    data() {
      return {
        isAdd: true,
        loaded: false,

        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {

        }
      },
      setData(data) {
        this.$refs.form.resetFields()
        if (data && data.orderId) {
          this.http.get(this, {
            url: this.api.orderLogistics.get,
            params: {
              orderId: data.orderId
            },
            success: function(me, data) {
              me.loaded = true
              me.formItem = data
            }
          })
          this.isAdd = false
        } else {
          this.formItem = this.getFormItem()
          this.loaded = true
        }
      },
      updateLogistics(e) {
        let obj = {}
        obj[e.id] = e.value
        obj['orderLogisticsId'] = this.formItem.orderLogisticsId
        this.http.post(this, {
          url: this.api.orderLogistics.update,
          data: obj,
          success: function(me, data) {

          }
        })
      },
      handleSubmit(callback) {
        this.$refs.form.submit({orderId:this.formItem.orderId}, callback)
      }
    },
    created() {

    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
